package com.ft.config;

import com.ft.model.enums.OrderStatusChangeEventEnum;
import com.ft.model.enums.OrderStatusEnum;
import com.ft.service.OrderStateService;
import com.ft.statemachine.recipes.persist.PersistEnumStateMachineHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.StateMachine;

/**
 * @author: zhangjianghua
 * @Date: 2018-10-10 12:45
 */
@Configuration
public class PersistStateMachineHandlerConfiguration {
    @Autowired
    private StateMachine<OrderStatusEnum, OrderStatusChangeEventEnum> stateMachine;

    @Bean
    public OrderStateService persist() {
        return new OrderStateService(persistStateMachineHandler());
    }

    @Bean
    public PersistEnumStateMachineHandler persistStateMachineHandler() {
        return new PersistEnumStateMachineHandler(stateMachine);
    }
}
